package com.glsc.ngateway.common.base.domain.mysql.gateway.other;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.api.common.enums.DictConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * @author zhouzp
 * @date 2020/6/17
 * 待发送邮件列表
 */
@Data
@Entity
@Table(name = "t_am_email_client")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class EmailClient {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "mail_id", columnDefinition = "int(20) comment 'mail_id'")
    private Integer mailId;

    @ApiModelProperty(value = "消息类型，字典：am_msg_type，1短信，2邮件，3-OA提醒")
    @Column(name = "msg_type", columnDefinition = "varchar(10) comment '消息类型，字典：am_msg_type'")
    private String msgType= DictConstant.MSG_TYPE_MAIL;

    @ApiModelProperty(value = "邮箱类型，字典：am_mail_type，1:邮箱一，1:邮箱二")
    @Column(name = "mail_type", columnDefinition = "varchar(10) comment '邮箱类型，字典：am_mail_type，1:邮箱一，1:邮箱二'")
    private String mailType= DictConstant.MAIL_TYPE_MAIL_DEFAULT;

    @Column(name = "sender", columnDefinition = "varchar(60) comment '发件人'")
    private String sender;

    @Column(name = "service_name", columnDefinition = "varchar(60) comment '系统名称'")
    private String serviceName;

    @Column(name = "recipient", columnDefinition = "varchar(1000) comment '收件人:多个收件人用,隔开'")
    private String recipient;

    @Column(name = "title", columnDefinition = "varchar(128) comment '邮件标题'")
    private String title;

    @Column(name = "content", columnDefinition = "text comment '邮件正文'")
    private String content;

    @ApiModelProperty(value = "文件路径列表")
    @Column(name = "file_path_list", columnDefinition = "varchar(200) comment '文件路径列表'")
    private String filePathList;

    @ApiModelProperty(value = "文件名称列表")
    @Column(name = "file_name_list", columnDefinition = "varchar(100) comment '文件名称列表'")
    private String fileNameList;

    @Column(name = "mail_status", columnDefinition = "varchar(16) default '01' comment '邮件状态， 字典 am_mail_status'")
    private String status = "1";


    @ApiModelProperty(value = "操作人员ID")
    @Column(name = "op_operator", columnDefinition = "varchar(20) COMMENT '操作人员ID'")
    protected String opOperator;

    @ApiModelProperty(value = "操作时间")
    @Column(name = "op_time", columnDefinition = "datetime comment '操作时间'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime opTime;

    @Column(name = "random_str", columnDefinition = "varchar(500) comment '邮件确认随机字符串'")
    private String randomStr;

    @Column(name = "remark", columnDefinition = "text comment '补充说明'")
    private String remark;
}
